<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>天天生鲜-用户中心</title>
	<link rel="stylesheet" type="text/css" href="css/reset.css">
	<link rel="stylesheet" type="text/css" href="css/main.css">
	<script type="text/javascript" src="js/vue.js"></script>
	<script type="text/javascript" src="js/axios.js"></script>
</head>
<body>
<div id="app">
	<div class="header_con">
		<div class="header">
			<div class="welcome fl">欢迎来到天天生鲜!</div>
			<div class="fr">
				<div class="user_link fl">
					<span>|</span>
					<a href="user_center_info.html">用户中心</a>
					<span>|</span>
					<a href="cart.html">我的购物车</a>
					<span>|</span>
					<a href="user_center_order.html">我的订单</a>
				</div>
			</div>
		</div>		
	</div>

	<div class="search_bar clearfix">
		<a href="index.html" class="logo fl"><img src="images/logo.png"></a>
		<div class="sub_page_name fl">|&nbsp;&nbsp;&nbsp;&nbsp;用户中心</div>
	</div>

	<div class="main_con clearfix">
		<div class="left_menu_con clearfix">
			<h3>用户中心</h3>
			<ul>
				<li><a href="user_center_info.html" class="active">· 个人信息</a></li>
				<li><a href="user_center_order.html">· 全部订单</a></li>
				<li><a href="user_center_site.html" >· 收货地址</a></li>
			</ul>
		</div>
		<div class="right_content clearfix">
				<div class="info_con clearfix">
				<h3 class="common_title2">基本信息</h3>
						<ul class="user_info_list">
							<li><span>用户名：</span>{{userinfo.nickName}}</li>
							<li><span>联系方式：</span>{{userinfo.email}}</li>
						</ul>
				</div>
				
				<h3 class="common_title2">最近浏览</h3>
				<div class="has_view_list">
				<ul class="goods_type_list clearfix">
					<div v-for="(his,index) in historydata" v-if="index<5">
						<li>
							<a :href="'details.html#'+his.gno"><img :src="'./'+his.pics"></a>
							<h4><a :href="'details.html#'+his.gno">{{his.gname}}</a></h4>
							<div class="operate">
								<span class="prize">￥{{his.price}}</span>
								<span class="unit">{{his.price}}/{{his.unit}}</span>
								<a :href="'details.html#'+his.gno" class="add_goods" title="加入购物车"></a>
							</div>
						</li>
					</div>
				</ul>
		</div>
		</div>
	</div>



	<div class="footer">
		<div class="foot_link">
			<a href="#">关于我们</a>
			<span>|</span>
			<a href="#">联系我们</a>
			<span>|</span>
			<a href="#">招聘人才</a>
			<span>|</span>
			<a href="#">友情链接</a>		
		</div>
		<p>CopyRight © 2016 北京天天生鲜信息技术有限公司 All Rights Reserved</p>
		<p>电话：010-****888    京ICP备*******8号</p>
	</div>
</div>
<script>
	Vue.prototype.axios = axios;
	axios.interceptors.request.use(config => {
				const token = localStorage.getItem('token');
				if (token) {
					config.headers.Authorization = token;
				} else {
					config.headers.Authorization = '';
				}
				console.log(token);
				console.log(config);
				return config;
			}, error => {
				return Promise.reject(error);
			}
	);
	axios.defaults.headers.post['Content-Type'] = 'application/json';
	let begin ="http://localhost:20001/";
	let security = "freshgood-security/";
	let goods = "freshgood-goods/";
	let cart = "freshgood-cart/";
	let order = "freshgood-order/"
	let vm = new Vue({
		el:"#app",
		data:{
			userinfo:{},
			historydata:[],
		},
		methods:{
			getHistory(){
				axios({
					url: "History",
					method: "get",
					params: {op: 'getHistory'}
				}).then(rs=>{
					this.historydata=rs.data;
				});
			},
			getUserInfo(){
				axios.post(begin+security+"security/freshgood/loginCheck").then(data => {
					if(data.data.code == 1) {
						// console.log(data.data);
						this.userinfo = data.data.user;
						// this.getHistory();
					}else{
						alert(data.data.msg);
						window.location.href="login.html";
					}
				})
			},
		},
		mounted(){
			this.getUserInfo();
			//this.getHistory();
		}
	})
</script>
</body>
</html>